package com.fjut.controller;


import com.fjut.model.vod.Video;
import com.fjut.result.Result;
import com.fjut.service.VideoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author DengTianxun
 * @since 2023-03-06
 */
@Api(tags = "小节（课时）接口")
@RestController
@RequestMapping("/fjut/vod/video")
//@CrossOrigin
public class VideoController {
    @Autowired
    private VideoService videoService;

    @ApiOperation("小节列表")
    @GetMapping("getLessonList/{id}")
    public Result getNestedTreeList(@PathVariable Long id){
        return Result.success(videoService.getById(id));
    }

    @ApiOperation("添加课程小节")
    @PostMapping("saveLessonInfo")
    public Result saveLessonInfo(@RequestBody Video video){
        return Result.success(videoService.save(video)).message("添加课程小节成功");
    }



    @ApiOperation("查询课程")
    @GetMapping("getLessonInfo/{id}")
    public Result getLessonInfo(@PathVariable Long id){
        return Result.success(videoService.getById(id));
    }

    @ApiOperation("修改课程大纲")
    @PostMapping("updateLessonInfo")
    public Result updateLessonInfo(@RequestBody Video video){
        return Result.success(videoService.updateById(video)).message("修改课程小节成功");
    }

    @ApiOperation("删除课程")
    @DeleteMapping("deleteLesson/{id}")
    public Result deleteLesson(@PathVariable Long id){
        videoService.removeVideoById(id);
        return Result.success(null).message("删除课程小节成功");
    }
}

